/*
 *  IOUSBPropertyLookup.h
 *  MusicAnalyzer
 *
 *  Created by jiro on 12/03/28.
 *  Copyright 2012 jiro music. All rights reserved.
 *
 */

#pragma once

#include <string>
#include <sstream>
#include "IOKit/IOKitLib.h"
#include "IOKit/usb/IOUSBLib.h"

using namespace std;

namespace sc
{
	class IOUSBPropertyLookup
	{
	public:
	
		static string GetIOUSBConfigurationDescriptorPtrAsStr( IOUSBConfigurationDescriptorPtr ptr, int tabCount )
		{
			string tabs;
			for ( int i = 0; i < tabCount; i++ )
			{
				tabs.append( "\t" );
			}
			
			stringstream sstr;
			sstr << tabs << "IOUSBConfigurationDescriptorPtr" << "\n";
			sstr << tabs<< "\t" << "bLength: " << static_cast<int>( ptr->bLength ) << "\n";
			sstr << tabs<< "\t" << "bDescriptorType: " << static_cast<int>( ptr->bDescriptorType ) << "\n";
			sstr << tabs<< "\t" << "wTotalLength: " << static_cast<int>( ptr->wTotalLength ) << "\n";
			sstr << tabs<< "\t" << "bNumInterfaces: " << static_cast<int>( ptr->bNumInterfaces ) << "\n";
			sstr << tabs<< "\t" << "bConfigurationValue: " << static_cast<int>( ptr->bConfigurationValue ) << "\n";
			sstr << tabs<< "\t" << "iConfiguration: " << static_cast<int>( ptr->iConfiguration )  << "\n";
			sstr << tabs<< "\t" << "bmAttributes: " << static_cast<int>( ptr->bmAttributes ) << "\n";
			sstr << tabs<< "\t" << "MaxPower: " << static_cast<int>( ptr->MaxPower ) << "\n";
			return sstr.str();
		}

		static string GetEndpointDirectionAsStr( int direction )
		{
			switch ( direction )
			{
			case kUSBOut:
				return "kUSBOut";
			case kUSBIn:
				return "kUSBIn";
			case kUSBNone:
				return "kUSBNone";
			case kUSBAnyDirn:
				return "kUSBAnyDirn";
			default:
				return "";
			}
		}

		static string GetTransferTypeAsString( int transferType )
		{
			switch ( transferType )
			{
			case kUSBControl:
				return "kUSBControl";
			case kUSBIsoc:
				return "kUSBIsoc";
			case kUSBBulk:
				return "kUSBBulk"; 
			case kUSBInterrupt:
				return "kUSBInterrupt";
			case kUSBAnyType:
				return "kUSBAnyType";
			default:
				return "";
			}
		}
	};
}